package
{
	import flash.display.Loader;
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.net.URLRequest;
	import flash.system.ApplicationDomain;
	import flash.system.LoaderContext;
	import ywh.model.Model1;
	import ywh.ui.SliderForContent;
	
	/**
	 * ...
	 * @author 杨伟华
	 */
	public class Test_Model1 extends Sprite
	{
		private var _chapterPath:String;
		private var _infoModel:Model1;
		
		public function Test_Model1()
		{
			addEventListener(Event.ADDED_TO_STAGE, addedToStage);
			this.stage.align = StageAlign.TOP_LEFT;
			this.stage.scaleMode = StageScaleMode.NO_SCALE;
		}
		
		private function addedToStage(e:Event):void
		{
			removeEventListener(Event.ADDED_TO_STAGE, addedToStage);
			var loader:Loader = new Loader();
			var context:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);
			loader.contentLoaderInfo.addEventListener(Event.INIT, init);
			loader.load(new URLRequest("utils.swf"), context);
		}
		
		private function init(e:Event):void
		{
			_infoModel = Model1.$;
			_infoModel.infoProvider = this;			
			addChild(_infoModel);
			chapterPath = "../datas/0101/";
		}
		
		public function set chapterPath(value:String):void
		{
			_chapterPath = value;
			_infoModel.changeChapterHandle();
		}
		
		public function getResolvePath(rp:String):String
		{
			//return File.documentsDirectory.resolvePath(_chapterPath + rp).url;
			return _chapterPath + rp;
		}
		
		public function map_handle():void
		{
			trace("map");
		}
		public function course_handle():void
		{
			trace("startCourse");
		}
	}
}